
package com.ucitech.filedb.example;

import com.ucitech.filedb.KeyGenerator;
import com.ucitech.filedb.Record;

/**
 *
 * @author Charlee
 */
public class ExampleRecord implements Record{
    private final String[] line = new String[4];

    public ExampleRecord(String csvdata) {
        System.arraycopy(csvdata.split(",",0), 0, line, 0, 4);
    }

    public ExampleRecord(String name, String address, String phoneNumber) {
        line[0] = KeyGenerator.getInstance().str();
        line[1] = name;
        line[2] = address;
        line[3] = phoneNumber;
    }

    @Override
    public String key() {
        return line[0];
    }

    public String name(){
        return line[1];
    }
    
    public String address(){
        return line[2];
    }
    
    public String phoneNumber(){
        return line[3];
    }

    @Override
    public String csv() {
        return String.format("%s,%s,%s,%s", line[0],line[1],line[2],line[3]);
    }
}
